


__kernel void f_SoundWavesSorting( __global float* c_location, __global uint* c_Index, 
                                    const uint c_Count, 
                                    uint c_Deepin) 
{
    uint id = get_global_linear_id()*2;
    uint id_end = id+1;
    if(c_Deepin < c_Count){
        if(c_Deepin&1){
            ++id;
            ++id_end;
        }

        if(id_end < c_Count  &&  id < c_Count-1){
            float b = c_location[id_end];
            uint i = c_Index[id_end];

            if(c_location[id] > b){
                c_location[id_end]  = c_location[id];
                c_location[id]      = b;

                c_Index[id_end] = c_Index[id];
                c_Index[id]     = i;
            }
        }
        
        if(id==0){
			//size_t work_size[3];
			ndrange_t ndrange1 = ndrange_1D( get_num_groups(0), 1);
			void(^func_SamplingBlock)(void) = ^{ f_SoundWavesSorting(c_location, c_Index, c_Count, c_Deepin+1); };
            
			int err_ret = enqueue_kernel(get_default_queue(), CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange1, func_SamplingBlock);
            printf("err %i", err_ret);
		}
    }
    

}



